//
//  MTMemberViewCell.swift
//  MT
//
//  Created by ooops on 2020/1/10.
//  Copyright © 2020 张强. All rights reserved.
//

import UIKit
import MTCategory

class MTMemberViewCell: UICollectionViewCell {
    
    class func reuseIdentity() -> String {
        return "MTMemberViewCellId"
    }
    
    public func bindDate(_ user : JMSGUser) {
        self.nickNameLabel.text = user.displayName()
        self.avatorImageView.mtSetImage(user.avatar, nil)
    }
    
    lazy var avatorImageView: UIImageView = {
        let imageV = UIImageView()
        imageV.layer.cornerRadius = 5
        imageV.layer.masksToBounds = true
        imageV.contentMode = .scaleAspectFill
        return imageV
    }()
    
    lazy var nickNameLabel: UILabel = {
        let l = UILabel()
        l.font = PingFangSCRegularFont(12)
        //l.textColor = UIColor.redpack.x5d5d5d
        l.textColor = .white
        l.text = ""
        l.textAlignment = .center
        return l
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor.theme.background
        contentView.backgroundColor = UIColor.theme.background
        setupUI()
        makeConstraint()
    }
    
    private func setupUI() {
        contentView.addSubview(avatorImageView)
        contentView.addSubview(nickNameLabel)
    }
    
    private func makeConstraint() {
        avatorImageView.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalToSuperview()
            make.width.equalToSuperview()
            make.height.equalTo(avatorImageView.snp.width)
            //make.width.height.equalTo(40)
        }
        
        nickNameLabel.snp.makeConstraints { (make) in
//            make.centerX.equalToSuperview()
//            make.top.equalTo(avatorImageView.snp.bottom)
            make.height.equalTo(20)
            make.left.right.equalToSuperview()
            make.bottom.equalToSuperview()
        }
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
}
